<%#
# To change this template, choose Tools | Templates
# and open the template in the editor.
%>


<%#
# To change this template, choose Tools | Templates
# and open the template in the editor.
%>
<script language="javascript">
function divmove(id){
  alert(document.getElementById(id).scroll);
  document.getElementById("college_list").scrollTop=scrollTo.document.getElementById(id);

}
</script>
<div style="clear:both"></div>
<div id ="l3">
  <div class="alphabet_links">
      <ul>
      <%i=65%>
      <% 26.times do %>
      <!--<div><a href="javascript:divmove('<#%=i.chr%>')" > <#%= i.chr %></a> </div>-->
      <div><a href="javascript:divmove('<%=i.chr%>')" > <%= i.chr %></a></div>

        <%i=i+1%>
      <%end%>
      </ul>
  </div>

<div class="left-column-colleges" >
<% form_remote_tag(:loading => "Element.show('activity');",:complete => "Element.hide('activity');" ,
   :update => "l2" , :url => {:controller => "modelwindow", :action => "modelwindow_view_university"} ) do -%>

 <div class="closeimage"  style="text-align:right" onclick="Dialog.okCallback();"><%= image_tag 'alphacube/button-close-focus.gif'%></div>
       <div class="sort_by">Sort by
       <input type="radio" name="check" <% if @val=="cities" %>   checked=true <%end%> value="cities" onclick="this.form.onsubmit();" >Cities
       <input type="radio" name="check" <% if @val=="alpha" %>   checked=true<%end%> value="alpha" onclick="this.form.onsubmit();">Alphabetical
      </div>
 <%end%>
 <%= image_tag 'spinner.gif', :id => 'activity', :style => 'display:none' %>

 <div id="college_list" class="colleges-name">
  <% if @val=="cities" %>
        <%  City.find(:all, :include => :universities ,:order => "name").each do |city| -%>
          <div class="city-institutes">
            <div class="city-window" id="<%=city.name[0..0]-%>"><%= h(city.name) -%></div>
             <%if city.universities.empty? -%>
                     No university available.
             <%else -%>
             <div class="institute-window">
                <%city.universities.each do |university| -%>
                <div><%= link_to_remote h(university.name), :update=>"l3" , :url => {:controller=>"post" , :action=>"page1" , :university =>university.name, :user_profile => params[:user_profile]} -%></div>
                <%end-%>
            </div>
            <%end-%>
          </div>
       <%end%>
  <%else%>
      <%
        alpha_univerity = Hash.new
       @universities.each do |university|
        alpha_univerity[university.name[0..0].upcase] = Array.new if alpha_univerity[university.name[0..0].upcase].nil?
        alpha_univerity[university.name[0..0].upcase] << university
        end
      %>
  <%"ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("").each do |alpha_letter| -%>
    <div class="city-institutes">
      <div class="city-window" id="<%=alpha_letter.upcase-%>"> <%=alpha_letter-%> </div>
       <%if alpha_univerity[alpha_letter].nil? %>
        No university available.
       <%else%>
       <div class="institute-window">
        <%alpha_univerity[alpha_letter].each do |university| -%>
        <div><%= link_to_remote h("#{university.name}, #{university.city.name}"), :update=>"l3" ,:url => { :controller=> "post" , :action=>"page1" , :university =>university.name, :user_profile => params[:user_profile]} -%></div>
        <%end%>
      </div>
      <%end%>
      <hr/>
     <%end%>
   </div>
  <%end%>
 </div>

  <div class="no-campus">Can't Find Your Campus ?</div>
</div>
<div style="clear:both"></div>
</div>




